package com.landian.commons.jpa.order;

import com.querydsl.core.types.Path;
import lombok.Getter;
import org.springframework.data.domain.Sort;

/**
 * Order
 *
 * @author caojl
 * @create 2017/12/14
 **/
public class Order {

    private Order(Path path, Sort.Direction direction){
        this.direction = direction;
        this.path = path;
    }

    /**
     *
     */
    @Getter
    private Sort.Direction direction;

    /**
     *
     */
    @Getter
    private Path<?> path;

    /**
     *
     * @return
     */
    public static Order asc(Path path){
        return new Order(path, Sort.Direction.ASC);
    }

    /**
     *
     * @return
     */
    public static Order desc(Path path){
        return new Order(path, Sort.Direction.DESC);
    }
}
